﻿<UserControl
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
	xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
	mc:Ignorable="d"
	xmlns:local="clr-namespace:UI"
	xmlns:Validators="clr-namespace:UI.Validators"
    xmlns:controls="clr-namespace:UI.Controls"
	xmlns:Custom="http://schemas.microsoft.com/wpf/2008/toolkit"
    xmlns:diagnostics="clr-namespace:System.Diagnostics;assembly=WindowsBase"
    xmlns:TypeConverters="clr-namespace:Infrastructure.TypeConverters;assembly=Infrastructure"
    xmlns:Controls1="clr-namespace:Infrastructure.Controls;assembly=Infrastructure"
	x:Class="UI.BookControl"
	x:Name="UserControl"
	d:DesignWidth="640" d:DesignHeight="480">

    <UserControl.Resources>
        <TypeConverters:StringToNumberConverter DefaultValue="1"  x:Key="numConverterOne" />
        <TypeConverters:StringToNumberConverter DefaultValue="{x:Null}"  x:Key="numConverterNull" />
        
        <Style TargetType="{x:Type TextBox}">
            <Setter Property="Validation.ErrorTemplate">
                <Setter.Value>
                    <ControlTemplate>
                        <DockPanel LastChildFill="True">
                            <Border BorderBrush="Red" BorderThickness="2">
                                <AdornedElementPlaceholder />
                            </Border>
                        </DockPanel>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
            <Style.Triggers>
                <Trigger Property="Validation.HasError" Value="true">
                    <Setter Property="ToolTip" 
                        Value="{Binding RelativeSource={RelativeSource Self}, 
                        Path=(Validation.Errors)[0].ErrorContent}"/>
                    <Setter Property="Background"
                            Value="AntiqueWhite" />
                </Trigger>
            </Style.Triggers>
        </Style>
    </UserControl.Resources>
    
	<DockPanel LastChildFill="True">
		<TabControl DockPanel.Dock="Top" TabStripPlacement="Left">
			<TabItem Header="Basic">
			
				<ScrollViewer VerticalScrollBarVisibility="Auto" >
					<DockPanel>
						<Grid>
							<Grid.RowDefinitions>
								<RowDefinition Height="Auto"/>
								<RowDefinition Height="Auto"/>
								<RowDefinition Height="Auto"/>
								<RowDefinition Height="Auto"/>
								<RowDefinition Height="*"/>
								
								
								
							</Grid.RowDefinitions>
							<Grid.ColumnDefinitions>
								<ColumnDefinition Width="Auto"/>
								<ColumnDefinition Width="*"/>
								<ColumnDefinition Width="Auto"/>
								<ColumnDefinition Width="Auto"/>
								<ColumnDefinition Width="*"/>
							</Grid.ColumnDefinitions>
							<GridSplitter x:Name="gridSplitter" 	HorizontalAlignment="Right" 
								VerticalAlignment="Stretch"
								Grid.Column="2" 
								Grid.RowSpan="7"
								ResizeBehavior="PreviousAndNext" Width="5" />
							<GroupBox Header="General" d:LayoutOverrides="Width, Height" Grid.ColumnSpan="2">
								<Grid>
									<Grid.RowDefinitions>
										<RowDefinition Height="Auto"/>
										<RowDefinition Height="Auto"/>
										<RowDefinition Height="Auto"/>
									</Grid.RowDefinitions>
									<Grid.ColumnDefinitions>
										<ColumnDefinition Width="Auto"/>
										<ColumnDefinition/>
									</Grid.ColumnDefinitions>
									<TextBlock x:Name="textBlock" VerticalAlignment="Top" Text="Title:" TextWrapping="Wrap"/>
									<TextBox x:Name="title" VerticalAlignment="Top" TextWrapping="Wrap" MinWidth="20" Grid.Column="1" Text="{Binding Title, UpdateSourceTrigger=LostFocus, ValidatesOnDataErrors=True}" />
									<WrapPanel Grid.Row="1" Grid.ColumnSpan="2">
										<StackPanel Orientation="Horizontal" Margin="0,0,5,0">
											<TextBlock x:Name="textBlock1" TextWrapping="Wrap" Text="ISBN:" HorizontalAlignment="Left" Margin="0,0,3,0"/>
											<TextBox x:Name="isbn" TextWrapping="Wrap" MaxLength="16" MaxLines="1" MinWidth="114" MinHeight="22" Text="{Binding ISBN, UpdateSourceTrigger=LostFocus, ValidatesOnDataErrors=True}" d:LayoutOverrides="Width"/>
										</StackPanel>
										<StackPanel Orientation="Horizontal" Margin="0,0,5,0">
											<TextBlock x:Name="textBlock2" Text="Binding:" TextWrapping="Wrap" d:LayoutOverrides="Width" Margin="0,0,3,0"/>
                                            <ComboBox x:Name="format" MinWidth="120" MinHeight="22" d:LayoutOverrides="Width" DisplayMemberPath="Text" SelectedItem="{Binding Format}" IsEditable="False"   >
                                                <ComboBox.ContextMenu>
                                                    <ContextMenu>
                                                        <MenuItem x:Name="AddBinding" Header="Add..." Click="MenuItem_Click" />
                                                        <MenuItem x:Name="EditBinding" Header="Edit..." Click="MenuItem_Click" />
                                                    </ContextMenu>
                                                </ComboBox.ContextMenu>
                                            </ComboBox>
                                        </StackPanel>
										<StackPanel Orientation="Horizontal" Margin="0,0,5,0">
											<TextBlock x:Name="textBlock3" HorizontalAlignment="Left" Text="Pages:" TextWrapping="Wrap" d:LayoutOverrides="HorizontalAlignment" Margin="0,0,3,0"/>
                                            <TextBox x:Name="numberOfPages" TextWrapping="Wrap" MaxLength="4" MaxLines="1" MinWidth="52" MinHeight="22"  d:LayoutOverrides="Width">
                                                <Binding Path="NumberOfPages" Converter="{StaticResource numConverterNull}" UpdateSourceTrigger="LostFocus" ValidatesOnDataErrors="True">
                                                    <Binding.ValidationRules>
                                                        <Validators:RegExValidationRule Expression="^\d*$" ErrorMessage="Only digits are allowed." />
                                                    </Binding.ValidationRules>
                                                </Binding>
                                            </TextBox>
                                        </StackPanel>
										<StackPanel Orientation="Horizontal" Margin="0,0,5,0">
											<TextBlock TextWrapping="Wrap" Margin="0,0,3,0" HorizontalAlignment="Left"><Run Text="Quantity:"/></TextBlock>
                                            <TextBox x:Name="quantity" TextWrapping="Wrap" MinWidth="25" HorizontalAlignment="Left">
                                                <Binding Path="Quantity"  Converter="{StaticResource numConverterOne}" UpdateSourceTrigger="LostFocus" ValidatesOnDataErrors="True">
                                                    <Binding.ValidationRules >
                                                        <Validators:RegExValidationRule Expression="^\d*$" ErrorMessage="Only digits are allowed." />
                                                    </Binding.ValidationRules>
                                                </Binding>
                                            </TextBox>
                                        </StackPanel>
										<StackPanel Orientation="Horizontal">
											<Label Content="Rating:"/>
											<Slider MinWidth="100" Maximum="5" SmallChange="1" TickPlacement="BottomRight" IsSnapToTickEnabled="True" Value="{Binding Rating}" />
										</StackPanel>
									</WrapPanel>
									<Label HorizontalAlignment="Left" VerticalAlignment="Bottom" Content="Publisher:" Grid.Row="2"/>
                                    <ComboBox x:Name="Publishers" VerticalAlignment="Bottom" Grid.Row="2" Grid.Column="1">
                                        <ComboBox.ContextMenu>
                                            <ContextMenu>
                                                <MenuItem x:Name="AddPublisher" Header="Add..." Click="MenuItem_Click" />
                                                <MenuItem x:Name="EditPublishers" Header="Edit..." Click="MenuItem_Click" />
                                            </ContextMenu>
                                        </ComboBox.ContextMenu>
                                    </ComboBox>
                                </Grid>
							</GroupBox>
							<DockPanel Grid.Column="3" d:LayoutOverrides="Width" Grid.ColumnSpan="2" Panel.ZIndex="500" LastChildFill="True">
								<StackPanel Orientation="Horizontal" d:LayoutOverrides="Height" Margin="0,0,0,7" DockPanel.Dock="Top" Panel.ZIndex="600">
									<TextBlock x:Name="textBlock4" VerticalAlignment="Top" Text="Authors:" TextWrapping="Wrap" HorizontalAlignment="Right" Width="44.284" d:LayoutOverrides="GridBox"/>
									<StackPanel Panel.ZIndex="999" Orientation="Horizontal">
										<Canvas Panel.ZIndex="999" Width="60">
											<Expander Header="Select" x:Name="selectAuthorExpander" Grid.Column="4" VerticalAlignment="Top" Expanded="selectAuthorExpander_Expanded">
												<Grid Background="Cornsilk" MaxHeight="500">
													<Grid.RowDefinitions>
														<RowDefinition />
														<RowDefinition />
														<RowDefinition />
														<RowDefinition />
													</Grid.RowDefinitions>
													<Grid.BitmapEffect>
														<DropShadowBitmapEffect />
													</Grid.BitmapEffect>

													<TextBlock Text="Author" FontWeight="Bold" FontSize="14" Margin="5,5,4.587,0" />
													<TextBlock Text="Set book author" FontWeight="Light" FontSize="10" Margin="5,0,0.587,13" Grid.Row="1"/>
									
													<ListBox x:Name="authorsList" Grid.Row="2" DisplayMemberPath="Name" ItemsSource="{Binding}" SelectionMode="Extended" />
													<Button x:Name="addSelectedAuthor" Grid.Row="3" Click="addSelectedAuthor_Click" Content="Add"/>
	                                
												</Grid>
											</Expander>
										</Canvas>
										<Canvas Panel.ZIndex="700" Width="60">
											<Expander Header="New" x:Name="addAuthorExpander" Grid.Column="4" VerticalAlignment="Top" Expanded="addAuthorExpander_Expanded" Panel.ZIndex="10000">
												<Grid Background="Cornsilk" MaxWidth="300">
													<Grid.BitmapEffect>
														<DropShadowBitmapEffect />
													</Grid.BitmapEffect>

													<Grid.RowDefinitions>
														<RowDefinition Height="Auto" />
														<RowDefinition Height="Auto" />
														<RowDefinition />
													</Grid.RowDefinitions>

													<TextBlock Text="New author" FontWeight="Bold" FontSize="14" Margin="5,5,5,0"/>
													<TextBlock Text="Save a new author" FontWeight="Light" FontSize="10" Margin="5,0,1,13" Grid.Row="1"/>
	                                
													<controls:AddAuthor x:Name="addAuthor" Grid.Row="2" CancelClicked="addAuthor_CancelClicked" AddClicked="addAuthor_AddClicked"/>
	                                
												</Grid>
											</Expander>
										</Canvas>						
									</StackPanel>
								</StackPanel>
								<ListBox x:Name="authors" DataContext="{Binding Authors, PresentationTraceSources.TraceLevel=High}" ItemsSource="{Binding}" DisplayMemberPath="Name" MinWidth="200" Panel.ZIndex="550" />
							</DockPanel>
							<GroupBox Header="Classification" Grid.Row="3" Grid.ColumnSpan="2">
								<Grid>
									<Grid.ColumnDefinitions>
										<ColumnDefinition Width="Auto"/>
										<ColumnDefinition/>
									</Grid.ColumnDefinitions>
									<Grid.RowDefinitions>
										<RowDefinition Height="Auto"/>
										<RowDefinition Height="Auto"/>
										<RowDefinition Height="Auto" />
									</Grid.RowDefinitions>
									<Label Content="Library of Congress:" HorizontalAlignment="Left" VerticalAlignment="Top"/>
									<TextBox x:Name="LoCClassification" Text="{Binding LoCClassification}"  TextWrapping="Wrap" VerticalAlignment="Top" d:LayoutOverrides="Width" Grid.Column="1" Margin="0,0,17,0"/>
									<Label Content="Dewey:" HorizontalAlignment="Left" Grid.Row="1"/>
									<TextBox x:Name="DeweyClassification" Text="{Binding DeweyClassification}" TextWrapping="Wrap" Grid.Row="1" Grid.Column="1" Margin="0,0,17,0"/>
									<Expander Header="More..." d:LayoutOverrides="Width" Grid.Row="2" Grid.ColumnSpan="2" VerticalAlignment="Top" DataContext="{Binding OtherClassification}">
										<Grid >
											<Grid.RowDefinitions>
												<RowDefinition Height="Auto"/>
												<RowDefinition Height="Auto"/>
												<RowDefinition Height="Auto"/>
												<RowDefinition Height="Auto"/>
												<RowDefinition Height="Auto"/>
												<RowDefinition Height="Auto"/>
												<RowDefinition Height="Auto"/>
												<RowDefinition Height="Auto"/>
												<RowDefinition Height="Auto"/>
												<RowDefinition Height="Auto"/>
												<RowDefinition Height="Auto"/>
											</Grid.RowDefinitions>
											<Grid.ColumnDefinitions>
												<ColumnDefinition Width="Auto"/>
												<ColumnDefinition/>
											</Grid.ColumnDefinitions>
											<Label Content="AARC:" d:LayoutOverrides="Width, Height" Grid.Row="0"/>
											<Label Content="CLC:" d:LayoutOverrides="Width, Height" Grid.Row="1"/>
											<Label Content="DC:" d:LayoutOverrides="Width, Height" Grid.Row="2"/>
											<Label Content="DOI:" d:LayoutOverrides="Width, Height" Grid.Row="3"/>
											<Label Content="Freinet:" d:LayoutOverrides="Width, Height" Grid.Row="4"/>
											<Label Content="HYCS:" d:LayoutOverrides="Width, Height" Grid.Row="5"/>
											<Label Content="ISBD:" d:LayoutOverrides="Width, Height" Grid.Row="6"/>
											<Label Content="MARC:" d:LayoutOverrides="Width, Height" Grid.Row="7"/>
											<Label Content="NBN:" d:LayoutOverrides="Width, Height" Grid.Row="8"/>
											<Label Content="UD:" d:LayoutOverrides="Width, Height" Grid.Row="9"/>
											
											
											<TextBox TextWrapping="Wrap" Text="{Binding AARC}" d:LayoutOverrides="Width, Height" Grid.Column="1" Grid.Row="0" Margin="0,0,17,0"/>
											<TextBox TextWrapping="Wrap" Text="{Binding CLC}" d:LayoutOverrides="Width, Height" Grid.Column="1" Grid.Row="1" Margin="0,0,17,0"/>
											<TextBox TextWrapping="Wrap" Text="{Binding DC}" d:LayoutOverrides="Width, Height" Grid.Column="1" Grid.Row="2" Margin="0,0,17,0"/>
											<TextBox TextWrapping="Wrap" Text="{Binding DOI}" d:LayoutOverrides="Width, Height" Grid.Column="1" Grid.Row="3" Margin="0,0,17,0"/>
											<TextBox TextWrapping="Wrap" Text="{Binding Freinet}" d:LayoutOverrides="Width, Height" Grid.Column="1" Grid.Row="4" Margin="0,0,17,0"/>
											<TextBox TextWrapping="Wrap" Text="{Binding HYCS}" d:LayoutOverrides="Width, Height" Grid.Column="1" Grid.Row="5" Margin="0,0,17,0"/>
											<TextBox TextWrapping="Wrap" Text="{Binding ISBD}" d:LayoutOverrides="Width, Height" Grid.Column="1" Grid.Row="6" Margin="0,0,17,0"/>
											<TextBox TextWrapping="Wrap" Text="{Binding MARC}" d:LayoutOverrides="Width, Height" Grid.Column="1" Grid.Row="7" Margin="0,0,17,0"/>
											<TextBox TextWrapping="Wrap" Text="{Binding NBN}" d:LayoutOverrides="Width, Height" Grid.Column="1" Grid.Row="8" Margin="0,0,17,0"/>
											<TextBox TextWrapping="Wrap" Text="{Binding UD}" d:LayoutOverrides="Width, Height" Grid.Column="1" Grid.Row="9" Margin="0,0,17,0"/>
											
										</Grid>
									</Expander>
								</Grid>
							</GroupBox>
							<Grid Grid.RowSpan="3" Grid.ColumnSpan="2" Grid.Row="4">
								<Grid.ColumnDefinitions>
									<ColumnDefinition />
									<ColumnDefinition Width="Auto" MinWidth="5" />
									<ColumnDefinition />
								</Grid.ColumnDefinitions>
                                <local:Category x:Name="CategoryList" />
                                <GridSplitter HorizontalAlignment="Stretch" Grid.Column="1" MinWidth="5"/>
								<local:KeywordSelector x:Name="KeywordList" d:LayoutOverrides="Width" Grid.Column="2" Margin="1,0,-1,0" />
							</Grid>
							<DockPanel Panel.ZIndex="150" Grid.Column="3" Grid.Row="3" Grid.ColumnSpan="2" Grid.RowSpan="2">
                            	<Label Content="Comment:" DockPanel.Dock="Top" HorizontalAlignment="Left" Panel.ZIndex="100" />
								<Controls1:RtfEditor x:Name="Comment" DocumentChanged="Comment_DocumentChanged" Panel.ZIndex="1" IsSaveVisible="Collapsed" />
							</DockPanel>
                        </Grid>
					</DockPanel>
				</ScrollViewer>
			
			</TabItem>
			<TabItem Header="Details">
				<Grid>
					<Grid.RowDefinitions>
						<RowDefinition Height="Auto"/>
						<RowDefinition Height="Auto"/>
						<RowDefinition Height="Auto"/>
						<RowDefinition Height="Auto"/>
						<RowDefinition Height="Auto"/>
						<RowDefinition Height="Auto"/>
						<RowDefinition Height="Auto"/>
						<RowDefinition Height="Auto"/>
					</Grid.RowDefinitions>
					<Grid.ColumnDefinitions>
						<ColumnDefinition Width="Auto"/>
						<ColumnDefinition/>
						<ColumnDefinition Width="Auto"/>
						<ColumnDefinition/>
					</Grid.ColumnDefinitions>
					<GroupBox VerticalAlignment="Top" Header="General" d:LayoutOverrides="Width" Grid.ColumnSpan="2" Grid.RowSpan="2">
						<Grid>
							<Grid.RowDefinitions>
								<RowDefinition Height="Auto"/>
								<RowDefinition Height="Auto"/>
								<RowDefinition Height="Auto"/>
								<RowDefinition Height="Auto"/>
								<RowDefinition Height="Auto"/>
								<RowDefinition Height="Auto"/>
								<RowDefinition Height="Auto"/>
							</Grid.RowDefinitions>
							<Grid.ColumnDefinitions>
								<ColumnDefinition Width="Auto"/>
								<ColumnDefinition/>
							</Grid.ColumnDefinitions>
							<Label VerticalAlignment="Top" Content="Series" d:LayoutOverrides="Width"/>
							<TextBox Text="{Binding Series}" VerticalAlignment="Top" TextWrapping="Wrap" d:LayoutOverrides="Width" Grid.Column="1"/>
							<Label VerticalAlignment="Top" Content="Edition" d:LayoutOverrides="Width" Grid.Row="1"/>
							<TextBox Text="{Binding Edition}" VerticalAlignment="Top" TextWrapping="Wrap" d:LayoutOverrides="Width" Grid.Column="1" Grid.Row="1"/>
							<Label Content="Volume:" d:LayoutOverrides="Width" VerticalAlignment="Bottom" Grid.Row="2"/>
							<TextBox Text="{Binding Volume}" TextWrapping="Wrap" d:LayoutOverrides="Width" Grid.Column="1" VerticalAlignment="Bottom" Grid.Row="2"/>
							<Label Content="Size:" d:LayoutOverrides="Width, GridBox" VerticalAlignment="Bottom" Grid.Row="3"/>
                            <StackPanel Orientation="Horizontal" VerticalAlignment="Bottom" Height="25.96" Grid.Column="1" d:LayoutOverrides="GridBox" Grid.Row="3">
                                <TextBox Text="{Binding Width, Converter={StaticResource numConverterNull}, ValidatesOnDataErrors=True, UpdateSourceTrigger=LostFocus}" TextWrapping="Wrap" d:LayoutOverrides="Width" MinWidth="40"/>
                                <TextBlock TextWrapping="Wrap" Text="X" TextAlignment="Center" VerticalAlignment="Center"/>
								<TextBox Text="{Binding Height, Converter={StaticResource numConverterNull}, ValidatesOnDataErrors=True, UpdateSourceTrigger=LostFocus}" TextWrapping="Wrap" MinWidth="40"/>
							</StackPanel>
							<Label VerticalAlignment="Bottom" Content="Witten in:" d:LayoutOverrides="Width" Grid.Row="4"/>
                            <Custom:DatePicker SelectedDate="{Binding DateWritten}" Grid.Row="4" Grid.Column="1"  />
							<Label Content="Chapters:" d:LayoutOverrides="Width, Height" Grid.Row="5"/>
							<TextBox Text="{Binding Chapter}"  TextWrapping="Wrap" d:LayoutOverrides="Width, Height" Grid.Row="5" Grid.Column="1"/>
						</Grid>
					</GroupBox>
					<GroupBox Margin="0,0,0,3" Header="Publisher" Grid.Column="2" Grid.ColumnSpan="2" d:LayoutOverrides="Width, Height">
						<Grid>
							<Grid.RowDefinitions>
								<RowDefinition Height="Auto"/>
								<RowDefinition Height="Auto"/>
								<RowDefinition Height="Auto"/>
								<RowDefinition Height="Auto"/>
								<RowDefinition Height="Auto"/>
							</Grid.RowDefinitions>
							<Grid.ColumnDefinitions>
								<ColumnDefinition Width="Auto"/>
								<ColumnDefinition/>
							</Grid.ColumnDefinitions>
							<Label Content="Country:" d:LayoutOverrides="Width"/>
							<ComboBox x:Name="Country" d:LayoutOverrides="Height" Grid.Column="1"/>
							<Label Content="Language:" Grid.Row="1" d:LayoutOverrides="Width"/>
							<ComboBox x:Name="Language" d:LayoutOverrides="Height" Grid.Row="1" Grid.Column="1"/>
							<Label Content="Format:" Grid.Row="2" d:LayoutOverrides="Width, Height"/>
							<TextBox x:Name="HowPublished" Text="{Binding HowPublished}" TextWrapping="Wrap" d:LayoutOverrides="Width, Height" Grid.Row="2" Grid.Column="1"/>
							<Label Content="Copyright:" Grid.Row="3" d:LayoutOverrides="Width, Height"/>
							<TextBox x:Name="Copyright" Text="{Binding Copyright}"  TextWrapping="Wrap" d:LayoutOverrides="Width, Height" Grid.Row="3" Grid.Column="1"/>
							<Label Content="Published in:" Grid.Row="4" d:LayoutOverrides="Width, Height"/>
							<Custom:DatePicker SelectedDate="{Binding DatePublished}" Grid.Row="4" Grid.Column="1"  />
						</Grid>
					</GroupBox>
				</Grid>
			</TabItem>
			<TabItem Header="Owner">
				<Grid>
					<Grid.ColumnDefinitions>
						<ColumnDefinition Width="Auto" />
						<ColumnDefinition Width="*" />
						<ColumnDefinition Width="Auto" />
						<ColumnDefinition Width="*" />
					</Grid.ColumnDefinitions>
					<Grid.RowDefinitions>
						<RowDefinition Height="Auto" />
						<RowDefinition Height="Auto" />
						<RowDefinition Height="Auto" />
						<RowDefinition Height="Auto" />
						<RowDefinition Height="Auto" />
						<RowDefinition Height="Auto" />
						<RowDefinition Height="Auto" />
						<RowDefinition Height="Auto" />
					</Grid.RowDefinitions>
					<GroupBox Margin="0" Header="General" d:LayoutOverrides="Width, Height" Grid.ColumnSpan="2" Grid.RowSpan="2">
						<Grid>
							<Grid.RowDefinitions>
								<RowDefinition Height="Auto"/>
								<RowDefinition Height="Auto"/>
								<RowDefinition Height="Auto"/>
								<RowDefinition Height="Auto"/>
								<RowDefinition Height="Auto"/>
								<RowDefinition Height="Auto"/>
							</Grid.RowDefinitions>
							<Grid.ColumnDefinitions>
								<ColumnDefinition Width="Auto"/>
								<ColumnDefinition/>
							</Grid.ColumnDefinitions>
							<Label HorizontalAlignment="Left" VerticalAlignment="Top" Content="Owner:" Target="{Binding ElementName=Owner}"/>
                            <ComboBox x:Name="Owner" d:LayoutOverrides="Height" Grid.Column="1">
                                <ComboBox.ContextMenu>
                                    <ContextMenu>
                                        <MenuItem x:Name="AddOwner" Header="Add..." Click="MenuItem_Click" />
                                        <MenuItem x:Name="EditOwner" Header="Edit..." Click="MenuItem_Click" />
                                    </ContextMenu>
                                </ComboBox.ContextMenu>
                            </ComboBox>
                            <Label Content="Location:" Grid.Row="1"/>
							<TextBox Text="{Binding Location}"  x:Name="Location" TextWrapping="Wrap" Grid.Row="1" Grid.Column="1"/>
							<Label Content="Current price:" d:LayoutOverrides="GridBox" Grid.Row="2"/>
							<TextBox Text="{Binding CurrentPrice}" TextWrapping="Wrap" d:LayoutOverrides="GridBox" Grid.Row="2" Grid.Column="1"/>
							<Label Content="Condition:" VerticalAlignment="Bottom" Grid.Row="3"/>
                            <ComboBox Grid.Row="3" Grid.Column="1" >
                                <ComboBox.ContextMenu>
                                    <ContextMenu>
                                        <MenuItem x:Name="AddCondition" Header="Add..." Click="MenuItem_Click" />
                                        <MenuItem x:Name="EditCondition" Header="Edit..." Click="MenuItem_Click" />
                                    </ContextMenu>
                                </ComboBox.ContextMenu>
                            </ComboBox>
                            <Label Content="Dedication:" Grid.Row="4" VerticalAlignment="Bottom"/>
							<TextBox Text="{Binding Dedication}"  TextWrapping="Wrap" Grid.Row="4" Grid.Column="1" VerticalAlignment="Bottom"/>
							<Label Content="Date of Reading:" d:LayoutOverrides="Height" Grid.Row="5"/>
							<Custom:DatePicker SelectedDate="{Binding ReadingDate}" Grid.Row="5" Grid.Column="1"  />
						</Grid>
					</GroupBox>
					<GroupBox Header="Purchase" d:LayoutOverrides="Width, Height" Grid.ColumnSpan="2" Grid.Column="2">
						<Grid>
							<Grid.ColumnDefinitions>
								<ColumnDefinition Width="Auto" />
								<ColumnDefinition Width="*" />
							</Grid.ColumnDefinitions>
							<Grid.RowDefinitions>
								<RowDefinition Height="Auto" />
								<RowDefinition Height="Auto" />
								<RowDefinition Height="Auto" />
								<RowDefinition Height="Auto" />
								<RowDefinition Height="Auto" />
								<RowDefinition Height="Auto" />
								<RowDefinition Height="Auto" />
								<RowDefinition Height="Auto" />
							</Grid.RowDefinitions>
							<Label Content="Date:" d:LayoutOverrides="Width" VerticalAlignment="Bottom" HorizontalAlignment="Left"/>
							<Custom:DatePicker SelectedDate="{Binding PurchaseDate}" Grid.Row="0" Grid.Column="1"  />
							<Label Content="Price:" VerticalAlignment="Bottom" Grid.Row="1"/>
							<TextBox Text="{Binding PurchasePrice}" TextWrapping="Wrap" Grid.Row="1" Grid.Column="2" VerticalAlignment="Center"/>
							<Label Content="Store:" VerticalAlignment="Bottom" Grid.Row="2"/>
                            <ComboBox IsReadOnly="True" VerticalAlignment="Bottom" Grid.Row="2" Grid.Column="2">
                                <ComboBox.ContextMenu>
                                    <ContextMenu>
                                        <MenuItem x:Name="AddStore" Header="Add..." Click="MenuItem_Click" />
                                        <MenuItem x:Name="EditStore" Header="Edit..." Click="MenuItem_Click" />
                                    </ContextMenu>
                                </ComboBox.ContextMenu>
                            </ComboBox>
                        </Grid>
					</GroupBox>
					
					<GroupBox Margin="0,0,0,3" Header="Borrow" Grid.Column="2" Grid.ColumnSpan="2" Grid.Row="1" d:LayoutOverrides="Width, Height">
						<Grid>
							<Grid.RowDefinitions>
								<RowDefinition Height="Auto"/>
								<RowDefinition Height="Auto"/>
							</Grid.RowDefinitions>
							<Grid.ColumnDefinitions>
								<ColumnDefinition Width="Auto"/>
								<ColumnDefinition/>
							</Grid.ColumnDefinitions>
							<Label Content="Borrower:" d:LayoutOverrides="Width, Height"/>
							<TextBox TextWrapping="Wrap" Grid.Column="1" d:LayoutOverrides="Width, Height"/>
                            <Label Content="Date:" Grid.Row="1" d:LayoutOverrides="Width, Height"/>
							<Custom:DatePicker SelectedDate="{Binding BorrowDate}" Grid.Row="1" Grid.Column="1"  />
						</Grid>
					</GroupBox>
					
				</Grid>
			</TabItem>
			<TabItem Header="Covers">
				<DockPanel LastChildFill="True">
					<!--<controls:AddCover Margin="0,0,-0.001,0" d:LayoutOverrides="Width, Height" DockPanel.Dock="Right" CoverAdded="AddCover_CoverAdded"/>-->						
                  
					<Grid>
						<Grid.RowDefinitions>
							<RowDefinition Height="*"  />
							<RowDefinition Height="Auto"  />
							<RowDefinition Height="*"  />
						</Grid.RowDefinitions>
                        <DockPanel VerticalAlignment="Stretch" LastChildFill="True">
                        	<TextBlock Text="Front:" TextWrapping="Wrap" DockPanel.Dock="Top" />
                            <ToolBar MinHeight="23" Panel.ZIndex="939" DockPanel.Dock="Top" >
                            	<ToolBarPanel Width="Auto" Orientation="Horizontal" Panel.ZIndex="996">
                                    <Canvas Panel.ZIndex="999" MinWidth="50">
                                        <Expander Header="Add">
                                            <Grid Background="Cornsilk">
                                                <Grid.BitmapEffect>
                                                    <DropShadowBitmapEffect />
                                                </Grid.BitmapEffect>
                                                <controls:AddCover Type="Front" d:LayoutOverrides="Width, Height" CoverAdded="AddCover_CoverAdded"/>
                                            </Grid>
                                        </Expander>
                                    </Canvas>
                                    <Button Panel.ZIndex="2" Content="Delete" Click="Button_Click" />
                            		<Button Panel.ZIndex="2" Content="Default"/>
                            	</ToolBarPanel>
                            </ToolBar>
                            <Custom:DataGrid x:Name="FrontCovers" Panel.ZIndex="100">
                        		<Custom:DataGrid.Columns>
                                    <Custom:DataGridTemplateColumn Header="Preview">
                                        <Custom:DataGridTemplateColumn.CellTemplate>
                                            <DataTemplate>
                                                <Image Source="{Binding Path.Uri}" Width="32" Height="32" />
                                            </DataTemplate>
                                        </Custom:DataGridTemplateColumn.CellTemplate>
                                    </Custom:DataGridTemplateColumn>
                        			<Custom:DataGridTextColumn Header="Description" Binding="{Binding Description}"/>
                        			<Custom:DataGridTextColumn Header="Size" Binding="{Binding Size}"/>
                        			<!--<Custom:DataGridTextColumn Header="Path" Binding="{Binding Path.Uri}"/>-->
                                    <Custom:DataGridCheckBoxColumn Header="Default" Binding="{Binding IsDefault}"/>
                        		</Custom:DataGrid.Columns>
                        	</Custom:DataGrid>
                        </DockPanel>
                        <GridSplitter HorizontalAlignment="Stretch" Grid.Row="1" MinHeight="5" Panel.ZIndex="50"/>
                        <DockPanel Grid.Row="2" Panel.ZIndex="769" LastChildFill="True">
                        	<TextBlock Text="Back:" TextWrapping="Wrap" DockPanel.Dock="Top" />
                        	<ToolBar MinHeight="23" Panel.ZIndex="779" DockPanel.Dock="Top">
                        		<ToolBarPanel Width="Auto" Orientation="Horizontal" Panel.ZIndex="789">
                                    <Canvas Panel.ZIndex="799" MinWidth="50">
                        			    <Expander Header="Add">
                                            <Grid Background="Cornsilk">
                                                <Grid.BitmapEffect>
                                                    <DropShadowBitmapEffect />
                                                </Grid.BitmapEffect>
                                                <controls:AddCover Type="Back" d:LayoutOverrides="Width, Height" CoverAdded="AddCover_CoverAdded"/>
                                            </Grid>
                                        </Expander>
                                    </Canvas>
                        			<Button Content="Delete"/>
                        			<Button Content="Default"/>
                        		</ToolBarPanel>
                        	</ToolBar>
                        	<Custom:DataGrid x:Name="BackCovers" Panel.ZIndex="100">
                        		<Custom:DataGrid.Columns>
                                    <Custom:DataGridTemplateColumn Header="Preview">
                                        <Custom:DataGridTemplateColumn.CellTemplate>
                                            <DataTemplate>
                                                <Image Source="{Binding Path.Uri}" Width="32" Height="32" />
                                            </DataTemplate>
                                        </Custom:DataGridTemplateColumn.CellTemplate>
                                    </Custom:DataGridTemplateColumn>
                        			<Custom:DataGridTextColumn Header="Description" Binding="{Binding Description}"/>
                        			<Custom:DataGridTextColumn Header="Size" Binding="{Binding Size}"/>
                        			<!--<Custom:DataGridTextColumn Header="Path" Binding="{Binding Path.Uri}"/>-->
                                    <Custom:DataGridCheckBoxColumn Header="Default" Binding="{Binding IsDefault}"/>
                        		</Custom:DataGrid.Columns>
                        	</Custom:DataGrid>
                        </DockPanel>
                    </Grid>
				</DockPanel>
			</TabItem>
			<TabItem Header="Links">
				<DockPanel>
					<ToolBar DockPanel.Dock="Top" Panel.ZIndex="997">
						<ToolBarPanel Orientation="Horizontal" Panel.ZIndex="998">
							<Canvas Panel.ZIndex="999" Margin="0,0,0,6" MinHeight="23" MinWidth="70" d:LayoutOverrides="Height">
								<Expander Header="New" x:Name="NewLinkExpander" Grid.Column="4" VerticalAlignment="Top" Expanded="selectAuthorExpander_Expanded">
                                    <Grid Background="Cornsilk" MaxHeight="500">
                                        <Grid.BitmapEffect>
                                            <DropShadowBitmapEffect />
                                        </Grid.BitmapEffect>
                                        <controls:AddLink x:Name="LinkCreator" LinkSaved="LinkCreator_LinkSaved"/>
                                    </Grid>
                                </Expander>
							</Canvas>
							<Button Width="75" Content="Delete" VerticalAlignment="Center" Margin="0,0,0,6"/>
						</ToolBarPanel>
					</ToolBar>
					<Custom:DataGrid x:Name="Links" Panel.ZIndex="100"/>
				</DockPanel>
			</TabItem>
		</TabControl>
	</DockPanel>
</UserControl>